# detection/inference_menu.py
from PyQt5.QtWidgets import QAction
from PyQt5.QtCore import QObject, pyqtSignal

class InferenceMenu(QObject):
    """
    推理菜单管理模块
    """
    adjust_params_signal = pyqtSignal()  # 打开参数调整页面
    start_inference_signal = pyqtSignal()
    pause_inference_signal = pyqtSignal()
    stop_inference_signal = pyqtSignal()

    def __init__(self, parent):
        super().__init__(parent)
        self.parent = parent
        self._create_actions()

    def _create_actions(self):
        # 调整参数
        self.adjust_params_action = QAction("调整参数", self.parent)
        self.adjust_params_action.setShortcut("Ctrl+I")
        self.adjust_params_action.triggered.connect(self.adjust_params_signal.emit)

        # 开始推理
        self.start_action = QAction("开始推理", self.parent)
        self.start_action.setShortcut("Ctrl+Shift+R")
        self.start_action.triggered.connect(self.start_inference_signal.emit)

        # 暂停推理
        self.pause_action = QAction("暂停推理", self.parent)
        self.pause_action.setShortcut("Ctrl+Shift+P")
        self.pause_action.triggered.connect(self.pause_inference_signal.emit)

        # 停止推理
        self.stop_action = QAction("停止推理", self.parent)
        self.stop_action.setShortcut("Ctrl+Shift+E")
        self.stop_action.triggered.connect(self.stop_inference_signal.emit)

    def menu_actions(self):
        """
        返回所有菜单项，供主窗口使用
        """
        return [
            self.adjust_params_action,
            self.start_action,
            self.pause_action,
            self.stop_action,
        ]
